utility to add lat lon columns to data.table by reference, joining on bgid
Source:R/latlon_join_on_bgid.R
latlon_join_on_bgid.Rdget expanded version of data.table, such as copy(blockgroupstats), with new lat,lon columns
Examples
# quick map of blockgroups in 1 state, shown as blockgroup centroids
myst <- "NY"
dat <- bgpts[fips2state_abbrev(substr(bgfips,1,2)) == myst, ]
mapfast(dat, radius = 0.1)
# same but popups have all the indicators from EJScreen
myst <- "NY"
dat <- copy(blockgroupstats[ST == myst, ])
#> Error in copy(blockgroupstats[ST == myst, ]): could not find function "copy"
# add latlon cols by reference:
latlon_join_on_bgid(dat)
#> Error in latlon_join_on_bgid(dat): could not find function "latlon_join_on_bgid"
# specify useful labels for the map popups
mapfast(dat, radius = 0.1,
labels = fixcolnames(names(dat), 'r', 'shortlabel'))
## or add the useful labels to the table 1st
names(dat) <- fixcolnames(names(dat), "r", "shortlabel")
mapfast(dat, radius = 0.1)
#> Replaced column names that were inferred to be and therefore renamed as the lat and/or lon columns!